#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_map>

using namespace std;

unordered_map<int, int> m1, m2;
typedef long long LL;

int main()
{
    
    int n, a, b;
    cin >> n >> a >> b;
    
    for (int i = 1 ; i <= a ; i ++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        m1[x] = y;
    }
    
    for (int i = 1 ; i <= b ; i ++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        m2[x] = y;
    }
    
    LL res = 0;
    for (auto t : m1)
        res += t.second * m2[t.first];
        
    cout << res << endl;
    
    return 0;
}